package com.kelvin.oocl.dataprocess.operation;

import java.util.Comparator;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;

import com.kelvin.oocl.dataprocess.db.DBData;
import com.kelvin.oocl.dataprocess.entity.Customer;

public class CustomerOpetation {
	public static Map<String, Customer> customers = DBData.assessData();
	
	public boolean add(Customer customer){
		if(null==customer){
			return false;
		}
		customers.put(customer.getId(), customer);
		return true;
	}
	
	public Set<Customer> sort(Comparator<Customer> comparator){
		Set<Customer> set = new TreeSet<>(comparator);
		for(String id:customers.keySet()){
			set.add(customers.get(id));
		}
		return set;
	}
}
